# -*- coding: utf-8 -*-
import json

def getCompanyMainList(request):
    
    #1数据
    request.cursor_standard.execute(request.formatSql('''
        select 
            company_name,
            social_credit,
            entry_sign,
            province,city,
            legal_person,
            company_type,
            registered_capital,
            registered_date,
            lxr,
            registered_address,
            business_address,
            city_code
        from standard.company_main 
        where  company_name like '%${company_name}%'
        and ('${entry_sign}' = 'all' or entry_sign = '${entry_sign}')
        and is_del = 'N'
        limit ${start} , ${rows} 
    '''))
    rows = request.cursor_standard.fetchall()
    
    #2页码
    request.cursor_standard.execute(request.formatSql('''
        select count(*)  as total
        from standard.company_main
        where  company_name like '%${company_name}%'
        and ('${entry_sign}' = 'all' or entry_sign = '${entry_sign}')
        and is_del = 'N'
    '''))
    total = request.cursor_standard.fetchone()['total']
    #print({'rows':rows,'total':total})
    return json.dumps({'rows':rows,'total':total}, ensure_ascii=False)